public class BinarySearch {
    public int WhileLoop(int[] ary, int target) {
        int low = 0;
        int high = ary.length- 1;
        while (low <= high) {
            int mid = low + ((high - low) >> 1);
            if (ary[mid] == target) return mid;
            if (ary[mid] > target) {
                high = mid - 1;
            }
            else {
                low = mid + 1;
            }
        }
        return -1;
    }
}
